<?php

namespace mpend\modules\user\models;

use Yii;
use common\helpers\Url;

/**
 * 会员栏信息
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class MemberAboutLogic extends \common\models\member\Member {

    /**
     * @inheritdoc
     */
    public function getPanel() {
        //永久黑名单
        if ($this->isBlack) {
            return null;
        }
        //无效
        if (!$this->isAvaild) {
            return null;
        }
        $type = $this->type;
        if ($type) {
            $icon = $type->iconUrl;
            $title = $type->name;
        } else {
            $title = '达人';
            $icon = Url::attach('assets/icons/talent.png');
        }
        $levelNo = $this->level ? $this->level->name : '';
        return [
            'icon' => $icon,
            'title' => $title,
            'level' => $levelNo,
            'weblink' => Url::weblink('commission'),
        ];
    }

    public function getHurdle() {
        //申请中
        if ($this->isApplying) {
            return [
                'icon' => Url::attach('assets/icons/crown.png'),
                'title' => '会员申请中',
                'button' => '查看进度',
                'user_id' => $this->user_id,
                'weblink' => Url::weblink('member'),
            ];
        }
        return null;
    }

    public static function promptApply() {
        return [
            'icon' => Url::attach('assets/icons/crown.png'),
            'title' => '达人会员',
            'button' => '申请开通',
            'weblink' => Url::weblink('member/service'),
        ];
    }

}
